<?php

class KewenanganDao{
	
	public function getKewenangan($id_kewenangan){
		$db=Database::getInstance();
        $con=$db->getConnection(1);

        $query="SELECT * FROM ref_kewenangan WHERE id_kewenangan='$id_kewenangan'";

        $result=$con->prepare($query);
        $result->execute();

        if($result->rowCount()==1){
            $data=$result->fetch();
            return $data['nama_kewenangan'];
        }

        return false;
	}

    public function getAllKewenangan($id_kewenangan){
        $db=Database::getInstance();
        $con=$db->getConnection(1);

        $query="SELECT * FROM ref_kewenangan ";
        if($id_kewenangan!='1'){
            $query.=" WHERE akses_level!='1'";
        }

        $result=$con->prepare($query);
        $result->execute();

        if($result->rowCount()>=1){
             return $result->fetchAll();
        }

        return false;
    }

}

class Kewenangan{
	
	var $id_kewenangan;
	var $nm_kewenangan;

}


?>